<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org"
      lang="zh-cn">
<head>
    <meta content="云之讯,云通讯,云通讯平台" name="keywords"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1, maximum-scale=1"/>
    <title>短信平台运营系统 </title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <link th:href="@{/resources/css/bootstrap.min14ed.css?v=3.3.6}" rel="stylesheet">
    <link th:href="@{/resources/css/font-awesome.min93e3.css?v=4.4.0}" rel="stylesheet">
    <!-- jqgrid-->
    <link th:href="@{/resources/css/animate.min.css}" rel="stylesheet">
	<link th:href="@{/resources/css/plugins/sweetalert/sweetalert.css}" rel="stylesheet">
	<link th:href="@{/resources/css/select2.css}" rel="stylesheet">
	<link th:href="@{/resources/css/style.min862f.css?v=4.1.0}" rel="stylesheet">
    <style>
        /* Additional style to fix warning dialog position */
        #alertmod_table_list_2 {
            top: 900px !important;
        }
		.select2 span{
			display:block !important;
			margin-top: 0px !important;
		}
		.select2-container {
			width: 171px !important;
		}
		.select2-dropdown {
			width: 175px !important;
		}
		.select2-container .select2-selection--single{
			width:175px;
		}
    </style>
</head>
<body class="gray-bg"><div th:replace="stat :: statCode"></div>
	<div class="wrapper wrapper-content animated fadeInRight">
	    <div class="row">
	        <div class="col-sm-12">
	            <div class="ibox "> 
	                <div class="ibox-content">

						<div class="pull-right tooltip-demo">
							<!--<a class="btn btn-danger btn-sm" data-toggle="tooltip" data-placement="top" title="返回" onclick="javascript:self.location=document.referrer;"><i class="fa fa-reply"></i>&nbsp;返回</a>-->
						</div>
						<!--<div class="row">-->
							<!--<div class="col-sm-12">-->
								<!--<div class="table-responsive">-->
								  <!--<table class="table">-->
									<!--<tr class="active">-->
										<!--<th>代理商ID</th>-->
										<!--<th>代理商名称</th>-->
										<!--<th>手机号码</th>-->
										<!--<th>代理商状态</th>-->
										<!--<th>认证状态</th>-->
										<!--<th>余额</th>-->
										<!--<th>注册时间</th>-->
									<!--</tr>-->
									<!--<tr>-->
										<!--<td th:text="${data.agent_id}"></td>-->
										<!--<td th:text="${data.agent_name}"></td>-->
										<!--<td th:text="${data.mobile}"></td>-->
										<!--<td th:text="${data.status_name}"></td>-->
										<!--<td th:text="${data.oauth_status_name}"></td>-->
										<!--<td th:text="${data.balance}"></td>-->
										<!--<td th:text="${data.create_time}"></td>-->
									<!--</tr>-->
								  <!--</table>-->
								<!--</div>-->
							<!--</div>-->
						<!--</div>-->
	                    <div class="row">
	                        <div class="col-sm-12 b-r">
	                            <form class="form-horizontal m-t" id="mainForm">
	                            	<input type="hidden" name="agent_id" id="agentId" th:value="${data.agent_id}"/>
	                            	<input type="hidden" name="smsp_img_url" id="smsp_img_url" th:value="${data.smsp_img_url}"/>
									<div class="form-group">
										<label class="col-sm-3 control-label">客户ID:</label>
										<div class="col-sm-8">
											<p class="form-control-static" th:text="${data.agent_id}"></p>
										</div>
									</div>
									<div class="form-group">
										<label class="col-sm-3 control-label">客户类型:</label>
										<div class="col-sm-8" th:switch="${data.agent_type}">
											<p class="form-control-static" th:case="1">销售代理商</p>
											<p class="form-control-static" th:case="2">品牌代理商</p>
											<p class="form-control-static" th:case="5">OEM代理商</p>

										</div>
									</div>
									<div class="form-group">
										<label class="col-sm-3 control-label">客户名称:</label>
										<div class="col-sm-8">
											<input type="text" class="form-control "   name="agent_name"  th:value="${data.agent_name}" placeholder="张三"/>
										</div>
									</div>
									<div class="form-group">
										<label class="col-sm-3 control-label">联系地址:</label>
										<div class="col-sm-8">
											<input type="text" class="form-control  " th:value="${data.address}"  id="address" name="address" />
										</div>
									</div>
									<div class="form-group">
										<label class="col-sm-3 control-label">邮箱:</label>
										<div class="col-sm-8">
											<input type="text" class="form-control"  id="email" name="email"  placeholder="123@163.com" th:value="${data.email}"/>
										</div>
									</div>
									<div class="form-group">
										<label class="col-sm-3 control-label">手机号码:</label>
										<div class="col-sm-8">
											<input type="text" class="form-control"  id="mobile" name="mobile" th:value="${data.mobile}" />
										</div>
									</div>
									<div class="form-group">
										<label class="col-sm-3 control-label">归属销售:</label>
										<input type="hidden" name="oldBelongSale" id="oldSaleId" th:value="${data.belong_sale}">
										<div class="col-sm-8">
											<select class="form-control saleSelect" name="belong_sale" id="saleSelect"  style="width: 250px"></select>
										</div>
									</div>
	                                <div class="form-group" th:if="${data.agent_type} eq 5">
									    <label class="col-sm-3 control-label">域名:</label>
									    <div class="col-sm-8">
									      <input type="text" class="form-control  isDomain"  id="domain" name="domain_name" th:value="${data.domain_name }" placeholder="例：oemclient.sms.ucpaas.com"/>
									    </div>
	                                </div>
	                                <div class="form-group" th:if="${data.agent_type} eq 5">
	                                	<label class="col-sm-3 control-label">版权文字:</label>
	                                    <div class="col-sm-8">
									      <input type="text" class="form-control"  id="copyright" name="copyright" th:value="${data.copyright_text}"  placeholder="例：2014-2018 深圳市云之讯网络技术有限公司 粤ICP备14046848号 " />
	                                    </div>
	                                </div>
	                                <div class="form-group" th:if="${data.agent_type} eq 5">
	                                	<label class="col-sm-3 control-label">导航栏背景色:</label>
	                                    <div class="col-sm-8">
									      <input type="text" class="form-control isHexColor" id="nav_backcolor" name="nav_backcolor" th:value="${data.navigation_backcolor }" maxlength="7"  placeholder="例如棕黑色为：#506470"/>
								        </div>
	                                </div>
	                                <div class="form-group" th:if="${data.agent_type} eq 5">
	                                	<label class="col-sm-3 control-label">导航栏文字颜色:</label>
	                                	<div class="col-sm-8">
									      <input type="text" class="form-control isHexColor" id="nav_text_color" name="nav_text_color" th:value="${data.navigation_text_color }"  maxlength="7"  placeholder="例如棕黑色为：#506470"/>
	                                	</div>
	                                </div>
	                                <!--<div class="form-group">-->
	                                    <!--<label class="col-sm-3 control-label">行业短信折扣率:</label>-->
	                                    <!--<div class="col-sm-8">-->
									      <!--<input type="number" class="form-control" id="hy_discount" name="hy_discount" th:value="${data.hy_sms_discount}"/>-->
	                                    <!--</div>-->
	                                <!--</div> -->
	                                <!--<div class="form-group">-->
	                                    <!--<label class="col-sm-3 control-label">营销短信折扣率:</label>-->
	                                    <!--<div class="col-sm-8">-->
									      <!--<input type="number" class="form-control" id="yx_discount" name="yx_discount" th:value="${data.yx_sms_discount }" />-->
	                                    <!--</div>-->
	                                <!--</div> -->
	                                <!--<div class="form-group">-->
	                                    <!--<label class="col-sm-3 control-label">国际短信折扣率:</label>-->
	                                    <!--<div class="col-sm-8">-->
									      <!--<input type="number" class="form-control" id="gj_discount" name="gj_discount" th:value="${data.gj_sms_discount }" />-->
	                                    <!--</div>-->
	                                <!--</div>-->


									<div class="form-group" th:if="${data.agent_type} eq 5">
										<label class="col-sm-3 control-label">测试短信赠送:</label>
										<div class="col-sm-8" style="width: 180px">
											<select class="form-control" name="productType" id="productType">
												<option value="0">行业+全网+全国</option>
											</select>
										</div>
										<div class="col-sm-8" style="width: 230px">
											<select class="form-control" name="productId" id="productId">
												<option value="">请选择产品</option>
												<option th:each="product : ${productInfoList}" th:value="${product.product_id}" th:text="${product.product_name}"></option>
											</select>
										</div>
										<div class="col-sm-8" style="width: 230px">
											<input type="text" id="productNum" name="productNum" class="form-control" placeholder="请填写赠送的短信条数">
										</div>

										<div class="col-sm-3" style="width: 200px">
											<label class="control-label">[0~100]</label>
										</div>

										<input type="hidden" id="oldProductId" th:value="${data.test_product_id}" th:if="${data.isHavetestSmsNum == 'yes'}">
										<input type="hidden" id="oldTestNum" th:value="${data.test_sms_number}" th:if="${data.isHavetestSmsNum == 'yes'}">

									</div>

									<div>
										<input type="hidden" id="h_tab_logo" name="h_tab_logo" value=""/>
										<input type="hidden" id="h_logo" name="h_logo" value=""/>
										<input type="hidden" id="h_company_logo" name="h_company_logo" value=""/>
										<input type="hidden" id="h_api_document" name="h_api_document" value=""/>
										<input type="hidden" id="h_FAQ_document" name="h_FAQ_document" value=""/>
									</div>
									<div class="form-group">
										<label class="col-sm-3 control-label">备注</label>
										<div class="col-sm-8">
											<input type="text" class="form-control" id="remark"  name="remark"  th:value="${data.remark}"/>
										</div>
									</div>
	                            </form>

             					<form class="form-horizontal" method="post" id="tab_logo_form" th:if="${data.agent_type} eq 5">
	                                <div class="form-group">
	                                    <label class="col-sm-3 control-label">标签页图标:<br/> (尺寸：48px*48px)</label>
	                                    <div class="col-sm-8">
											<img id="preview_tab_logo" style="width: 48px;height: 48px;cursor: pointer;" name="preview_tab_logo" class="eg-preview" th:src="@{/resources/img/tab-logo_model.png}" alt="示例：标签图标" th:if="${#strings.isEmpty(data.tab_logo_url)}" />
											<img id="preview_tab_logo" style="width: 48px;height: 48px;cursor: pointer;" name="preview_tab_logo" class="eg-preview" th:src="${data.smsp_img_url}+'/file/scanPic.html?path='+${data.tab_logo_url}" alt="示例：标签图标"  th:unless="${#strings.isEmpty(data.tab_logo_url)}"/>
											<br><input type="file" accept="image/x-icon" id="tab_logo" name="tab_logo"/>
	                                    </div>
	                                </div>
             					</form>

					            <form class="form-horizontal" method="post" id="logo_form" th:if="${data.agent_type} eq 5">
	                                <div class="form-group">
	                                    <label class="col-sm-3 control-label">LOGO图:<br/> (尺寸：41px*43px)</label>
	                                    <div class="col-sm-8">
											<img id="preview_logo" class="eg-preview" style="width: 41px;height: 43px;cursor: pointer;" th:src="@{/resources/img/logo_model.png}" alt="示例：logo"  th:if="${#strings.isEmpty(data.logo_url)}" />
											<img id="preview_logo" class="eg-preview" style="width: 41px;height: 43px;cursor: pointer;" th:src="${data.smsp_img_url}+'/file/scanPic.html?path='+${data.logo_url}" alt="示例：logo" th:unless="${#strings.isEmpty(data.logo_url)}"/>
											<br><input type="file" accept="image/png" id="logo" name="logo"/>
	                                    </div>
	                                </div>
					            </form>
             					<form class="form-horizontal" method="post" id="company_logo_form" th:if="${data.agent_type} eq 5">
	                                <div class="form-group">
	                                    <label class="col-sm-3 control-label">LOGO + 公司名称图:<br/> (尺寸：184px*30px)</label>
	                                    <div class="col-sm-8">
											<img id="preview_company_logo" class="eg-preview" style="width: 184px;height: 30px;cursor: pointer;" th:src="@{/resources/img/logo-company_model.png}" alt="示例：logo+公司名"   th:if="${#strings.isEmpty(data.company_logo_url)}"/>
											<img id="preview_company_logo" class="eg-preview" style="width: 184px;height: 30px;cursor: pointer;" th:src="${data.smsp_img_url}+'/file/scanPic.html?path='+${data.company_logo_url}" alt="示例：logo+公司名"  th:unless="${#strings.isEmpty(data.company_logo_url)}"/>
											<br><input type="file" id="company_logo" name="company_logo" accept="image/png" />
	                                    </div>
	                                </div>
             					</form>
             					<form class="form-horizontal" method="post" id="api_document_Form" th:if="${data.agent_type} eq 5">
	                                <div class="form-group">
	                                    <label class="col-sm-3 control-label">接口文档<br/>(文件不大于5MB):</label>
	                                    <div class="col-sm-8">
											<a th:href="${data.smsp_img_url}+'/file/downloadFile.html?path='+${data.api_document_url}" th:text="'原接口文档'"  th:unless="${#strings.isEmpty(data.api_document_url)}" ></a>
											 <input type="file"  class="form-control" id="api_document" name="api_document" accept="application/vnd.openxmlformats-officedocument.wordprocessingml.document" />
	                                    </div>
	                                </div>
             					</form>
					            <form class="form-horizontal" method="post" id="FAQ_document_Form" th:if="${data.agent_type} eq 5">
	                                <div class="form-group">
	                                    <label class="col-sm-3 control-label">FAQ文档<br/>(文件不大于5MB):</label>
	                                    <div class="col-sm-8">
											<a  th:href="${data.smsp_img_url}+'/file/downloadFile.html?path='+${data.FAQ_document_url}" th:text="'原FAQ文档'" th:unless="${#strings.isEmpty(data.FAQ_document_url)}"></a>
											 <input type="file"  class="form-control" id="FAQ_document" name="FAQ_document" accept="application/vnd.openxmlformats-officedocument.wordprocessingml.document" />
	                                    </div>
	                                </div>
					            </form>
								<form class="form-horizontal" method="post" id="agent_status_Form">
								<div class="form-group">
									<label class="col-sm-3 control-label">客户状态:</label>
									<div class="col-sm-8">
										<p class="form-control-static" th:text="${data.status_name}" ></p>
									</div>
								</div>

								<div class="form-group">
									<label class="col-sm-3 control-label">认证状态:</label>
									<div class="col-sm-8">
										<p class="form-control-static" th:text="${data.oauth_status_name}"></p>
									</div>
								</div>
								<div class="form-group">
									<label class="col-sm-3 control-label">认证时间:</label>
									<div class="col-sm-8">
										<p class="form-control-static" th:text="${data.oauth_date}"></p>
									</div>
								</div>

								<div class="form-group">
									<label class="col-sm-3 control-label">证件类型:</label>
									<div class="col-sm-8">
										<p class="form-control-static" th:text="${data.id_type}"></p>
									</div>
								</div>
								<div class="form-group">
									<label class="col-sm-3 control-label">证件号码:</label>
									<div class="col-sm-8">
										<p class="form-control-static" th:text="${data.id_nbr}"></p>
									</div>
								</div>
									<div class="form-group">
										<label class="col-sm-3 control-label">证件图片:</label>
										<div class="col-sm-8">
											<img th:src="${data.smsp_img_url}+'/file/scanPic.html?path='+${data.img_url}"
												 width="50" height="35" style="cursor: pointer;" title="点击查看大图"
												 onclick="viewFile(this)" th:if="${data.img_url}"/>
										</div>
									</div>
								<div class="form-group">
									<label class="col-sm-3 control-label">账户余额（元） :</label>
									<div class="col-sm-8">
										<p class="form-control-static" th:text="${data.balance}"></p>
									</div>
								</div>
								<div class="form-group">
									<label class="col-sm-3 control-label">授信额度（元） :</label>
									<div class="col-sm-8">
										<p class="form-control-static" th:text="${data.credit_balance}"></p>
									</div>
								</div>

								<div class="form-group">
									<label class="col-sm-3 control-label">创建时间:</label>
									<div class="col-sm-8">
										<p class="form-control-static" th:text="${data.create_time}"></p>
									</div>
								</div>
								<div class="form-group">
									<label class="col-sm-3 control-label">修改时间 :</label>
									<div class="col-sm-8">
										<p class="form-control-static" th:text="${data.update_date}"></p>
									</div>
								</div>
								</form>

             					<form class="form-horizontal" >
								     <div class="form-group">
								        <div class="col-sm-12 col-sm-offset-3">
								            <button type="button" class="btn btn-sm btn-success" onclick="uploadData(this)">提交</button> 
								            <button type="button" class="btn btn-sm btn-error" onclick="goback()">返回</button> 
								        </div>
								    </div>
             					</form>
	                        </div>
	                    </div>
	                </div>
	            </div>
	        </div>
	    </div>
	</div>
	<script th:src="@{/resources/js/hex_ha_ha_ha_ha_ha.js}"></script>
	<script th:src="@{/resources/js/jquery.min.js?v=2.1.4}"></script>
	<script th:src="@{/resources/js/bootstrap.min.js?v=3.3.6}"></script>
	<script th:src="@{/resources/js/plugins/peity/jquery.peity.min.js}"></script>
	<script th:src="@{/resources/js/content.min.js?v=1.0.0}"></script>
	<script th:src="@{/resources/js/date_format.min.js?v=1.0.0}"></script>
	<script th:src="@{/resources/js/jquery.form.js?v=1.0.0}"></script>

	<script th:src="@{/resources/js/plugins/sweetalert/sweetalert.min.js}"></script>
	<script th:src="@{/resources/js/plugins/validate/jquery.validate.min.js}"></script>
	<script th:src="@{/resources/js/layer/layer.js}"></script>
	<script th:src="@{/resources/js/common.js?v=1.0.0}"></script>
	<script th:src="@{/resources/js/select2.min.js}"></script>

	<script th:inline="javascript">
		/*<![CDATA[*/
        function viewFile(img) {
            open($(img).attr("src"), "viewFile");
        }
        var agent_type = [[${data.agent_type}]];


        $(function () {

            //初始化销售id和原因
            var oldProductId = $('#oldProductId').val();
            var oldTestNum = $('#oldTestNum').val();
            var oldSaleId = $('#oldSaleId').val();


            //加载代理商和销售

            var  sale_list = [];
            $.ajax({
                url : '/accountInfo/client/add/data2',
                type : "GET",
                success : function (res) {
                    if(res.code != "0"){
                        return;
                    }

                    for(var i = 0; i < res.data.saleList.length; i++){
                        sale_list[i] = {};
                        sale_list[i].id = res.data.saleList[i].id;
                        sale_list[i].text = res.data.saleList[i].name;
                    }
                    //初始化select2

                    $("#saleSelect").select2({
                        data : sale_list
                    })
                    $("#saleSelect").val(oldSaleId).trigger('change')
                }
            })


            if(oldProductId != null && oldProductId != ''){
                $("#productId").val(oldProductId);
            }

            if(oldTestNum != null && oldTestNum != ''){
                $("#productNum").val(oldTestNum);
            }

            if(oldSaleId != null && oldSaleId != ''){
                $("#saleSelect").val(oldSaleId);
            }

        });


$.extend($.validator.messages, {
    required: "必选字段",
    remote: "请修正该字段",
    email: "请输入正确格式的电子邮件",
    url: "请输入合法的网址",
    date: "请输入合法的日期",
    dateISO: "请输入合法的日期 (ISO).",
    number: "请输入合法的数字",
    digits: "只能输入整数",
    creditcard: "请输入合法的信用卡号",
    equalTo: "请再次输入相同的值",
    accept: "请输入拥有合法后缀名的字符串",
    maxlength: $.validator.format("请输入一个长度最多是 {0} 的字符串"),
    minlength: $.validator.format("请输入一个长度最少是 {0} 的字符串"),
    rangelength: $.validator.format("请输入一个长度介于 {0} 和 {1} 之间的字符串"),
    range: $.validator.format("请输入一个介于 {0} 和 {1} 之间的值"),
    max: $.validator.format("请输入一个最大为 {0} 的值"),
    min: $.validator.format("请输入一个最小为 {0} 的值")
});
  	var mainFlag = /*[[${data.edit}]]*/;
  	var validate;
  	//msg消失时间
	var msgTime = 1500;
  	$(function(){
  		$.validator.defaults.ignore = "";
  		//表单验证规则
  		validate = $("#mainForm").validate({
  			rules: {
  				domain:{
  					required:true,
  					minlength:1,
  					maxlength:200
  				},
  				copyright:{
  					required:true,
  					minlength:10,
  					maxlength:200
  				},
  				nav_backcolor: {
 	 				required:true,
 	 				minlength:4,
  					maxlength:7
  				},
  				nav_text_color: {
 	 				required:true,
 	 				minlength:4,
  					maxlength:7
  				},
  				hy_discount: {
  					required:true,
					min:0,
					max:1
  				},
  				yx_discount: {
  					required:true,
					min:0,
					max:1
  				},
  				gj_discount: {
  					required:true,
					min:0,
					max:1
  				},
  			},
  			messages: {
  				domain:{
  					required:'请输入域名',
  					minlength:'',
  					maxlength:'域名长度请保持在200个字符以内'
  				},
  				copyright:{
  					required:'请输入企业版权文字说明',
  					minlength:'请保持版权文字格式正确',
  					maxlength:'版权文字内容请保持在200个字符以内'
  				},
  				nav_backcolor: {
 	 				required:'请输入导航栏背景色,16进制颜色码',
 	 				minlength:'请输入正确的16进制颜色码',
  					maxlength:'16进制颜色码,最多只需要填写7位'
  				},
  				nav_text_color: {
 	 				required:'请输入导航栏文字颜色,16进制颜色码',
 	 				minlength:'请输入正确的16进制颜色码',
  					maxlength:'16进制颜色码,最多只需要填写7位'
  				},
  				hy_discount: {
  					required:'请输入行业短信折扣率',
					min:'折扣率不能为负',	
					max:'行业短信折扣率不能超过 1.0'
  				},
  				yx_discount: {
  					required:'请输入营销短信折扣率',
					min:'折扣率不能为负',
					max:'营销短信折扣率不能超过 1.0'
  				},
  				gj_discount: {
  					required:'请输入国际短信折扣率',
					min:'折扣率不能为负',
					max:'国际短信折扣率不能超过 1.0'
  				},
  			}
  		});
  		
  		// 域名校验   
		jQuery.validator.addMethod("isDomain", function(value, element) {   
		    var tel = /^([\w-]+\.)+[\w-]+(\/[\w- .\/?%&=]*)?/;
		    return this.optional(element) || (tel.test(value));
		}, "请输入的正确格式的域名");
  		// 16进制颜色码检验
		jQuery.validator.addMethod("isHexColor", function(value, element) {   
		    var tel = /^#[0-9a-fA-F]{6}$/;
		    return this.optional(element) || (tel.test(value));
		}, "请输入正确格式的16进制颜色码");
  		
  		$('input[type="file"]').change(function() {
			var $file = $(this);
			var id = $file.attr("id");
			var fileObj = $file[0];
			var windowURL = window.URL || window.webkitURL;
			var dataURL;
			var $img = $("#preview_" + id);
			if(fileObj && fileObj.files && fileObj.files[0]){
				dataURL = windowURL.createObjectURL(fileObj.files[0]);
				fileUrl = fileObj.files[0];
				$img.attr('src',dataURL);
			}else{
				dataURL = $file.val();
				fileObj.files[0] = fileUrl;
//					$file.val(fileUrl);
				var imgObj = document.getElementById("preview_" + id);
//					imgObj.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale)";
//					imgObj.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = dataURL;
			}
		});
  	});

        //点击查看大图
        function viewFile(img) {
            open($(img).attr("src"), "viewFile");
        }

  	function uploadForm(formId,url,hid){
  		var uploadFlag = false;
  		var options = {
 	 			url:url,
 	 			async: false,
 	 			success : function(data) {
	 				if(data == "" || data == null || data.result == null) {
	 					layer.alert("服务器错误，请联系管理员", {
	 						icon : 2
	 					});
	 				}else if (data.result == "success") {
	 					$("#"+hid).val(data.path1);
	 					uploadFlag = true;
	 				}
 	 			},

 	 			type : "post",
 	 			dataType: 'json',
 	 			timeout : 10000
 	 		};
  		$("#"+ formId).ajaxSubmit(options);
  		return uploadFlag;
  	}
  	
	var maxsize = 5*1024*1024;//2M  
	var errMsg = "上传的附件文件不能超过5M！！！";  
    var browserCfg = {};  
	var fileFlag = false;
	function checkFile(id,tipMsg){
        var ua = window.navigator.userAgent;  
        if (ua.indexOf("MSIE")>=1){  
            browserCfg.ie = true;  
        }else if(ua.indexOf("Firefox")>=1){  
            browserCfg.firefox = true;  
        }else if(ua.indexOf("Chrome")>=1){  
            browserCfg.chrome = true;  
        }  
		fileFlag = false;
		var file = $("#"+id);
		  
		if (mainFlag != 'update' && file.val() == '') {
			layer.msg('<p style="color:black">选择需要上传的：'+tipMsg+'</p>',{
				icon : 2
			});
			return fileFlag;
		}else if(mainFlag == 'update' && file.val() == ''){
			fileFlag = true;
			return fileFlag;
		}
		
        var filesize = 0;  
        if(browserCfg.firefox || browserCfg.chrome ){  
            filesize = file[0].files[0].size;  
        }else if(browserCfg.ie){  
        	 fileFlag = false;
             var obj_file = $("#"+id);  
             obj_file.dynsrc=file.value;  
             filesize = obj_img.fileSize;  
         }else{  
			 fileFlag = true;
             return fileFlag;  
         }  
     
		if (filesize == 0) {
			layer.msg('<p style="color:black">选择需要上传的：'+tipMsg+'</p>', {
				icon : 2
			});
			return fileFlag
		} else if (filesize > maxsize) {
			layer.alert(errMsg, {
				icon : 2
			});
			return fileFlag;
		} else {
			fileFlag = true;
			return fileFlag;
		}
	}

	function uploadData(btn) {
		if(!validate.form()){
			return;
		}

        //校验测试产品
        var productId = $("#productId").val();
        var productNum = $("#productNum").val();
        if(productId != null && productId != ''){
            if(productNum == null || productNum == ''){
                layer.msg("请输入赠送数量！", {icon: 2,time: msgTime});
                return;
            }

            var pattern = /^(0|[1-9][0-9]*)$/;//正整数
            if(!pattern.test(Number(productNum))){
                layer.msg("赠送数量只能是[0~100]的正整数！", {icon: 2,time: msgTime});
                $("#productNum").val('');
                return;
            }

            if(productNum < 0 || productNum >100){
                layer.msg("赠送数量只能是[0~100]的正整数！", {icon: 2,time: msgTime});
                $("#productNum").val('');
                return;
            }
        }


        if(productNum != null && productNum != '' && productNum != '0'){
            if(productId == null || productId == ''){
                layer.msg("请选择产品！", {icon: 2,time: msgTime});
                return;
			}
		}



//		if (!checkFile("tab_logo","标签页图标")) {
//			return;
//		}
//		if (!checkFile("logo","LOGO图")) {
//			return;
//		}
//		if (!checkFile("company_logo","LOGO + 公司名称图")) {
//			return;
//		}
//		if (!checkFile("api_document","接口文档")) {
//			return;
//		}
//		if (!checkFile("FAQ_document","FAQ文档")) {
//			return;
//		}
		if(agent_type==5){
            ityzl_SHOW_LOAD_LAYER("资料上传中,请稍后...");
            var upLoadUrl = $("#smsp_img_url").val()
                + "/upload/multiUpload.html";
            if ($("#tab_logo").val() != "" && ! uploadForm("tab_logo_form", upLoadUrl, "h_tab_logo")) {
                return;
            };
            if ($("#logo").val() != "" && ! uploadForm("logo_form", upLoadUrl, "h_logo")) {
                return;
            };
            if ($("#company_logo").val() != "" && ! uploadForm("company_logo_form", upLoadUrl,"h_company_logo")) {
                return;
            };
            if ($("#api_document").val() != "" && ! uploadForm("api_document_Form", upLoadUrl,"h_api_document")) {
                return;
            };
            if ($("#FAQ_document").val() != "" && ! uploadForm("FAQ_document_Form", upLoadUrl,"h_FAQ_document")) {
                return;
            };
		}


		var editUrl =  /*[[@{/accountInfo/oem/edit}]]*/;

		var options = {
			beforeSubmit : function() {
				$(btn).attr("disabled", true);
				ityzl_SHOW_LOAD_LAYER("马上完成...");
			},
			url : editUrl,
			async : false,
			success : function(data) {
				layer.closeAll(); //疯狂模式，关闭所有层
				$(btn).attr("disabled", false);
				if (data == "" || data == null) {
					return; //session超时
				}
				$(btn).attr("disabled", false);
				if (data.success) {
					layer.msg(data.msg, {icon: 1,time: msgTime},function(){
                        var viewUrl =  /*[[@{/accountInfo/agent/view}]]*/;
						window.location.href=viewUrl+"?agentId="+$("#agentId").val();
					}); 
				}else{
//					layer.msg(data.msg, {
//						icon : 2
//					});
				}
			},
			type : "post"
		}
		$("#mainForm").ajaxSubmit(options);
	}
	
	function goback(){
		var editUrl =  /*[[@{/accountInfo/agent/view}]]*/;
		window.location.href=editUrl+"?agentId="+$("#agentId").val();
	}
	
	//loading 效果
	function ityzl_SHOW_LOAD_LAYER(msg){  
	    return layer.msg('<div style="color:#506470;font-family: "microsoft yahei","Arial Narrow",HELVETICA;">'+msg+'</div>', {icon: 16,shade: [0.5, '#f5f5f5'],scrollbar: false,offset: 'auto',time: 600000}) ;  
	}
	    /*]]>*/
	    
	</script>
</body>
</html>